package com.javasm.mb_store_api_final.giftsandgoods.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javasm.mb_store_api_final.giftsandgoods.goods.entity.GgGoods;
import com.javasm.mb_store_api_final.giftsandgoods.product.dao.GgProductDao;
import com.javasm.mb_store_api_final.giftsandgoods.product.entity.GgProduct;
import com.javasm.mb_store_api_final.giftsandgoods.product.service.GgProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 商品管理-产品查询
(GgProduct)表服务实现类
 *
 * @author makejava
 * @since 2024-08-01 21:03:32
 */
@Service("ggProductService")
public class GgProductServiceImpl extends ServiceImpl<GgProductDao, GgProduct> implements GgProductService {

    @Resource
    private GgProductDao ggProductDao;
    @Override
    public GgProduct getByCoding(String gcode) {
        GgProduct product = ggProductDao.getByCoding(gcode);
        return product;
    }

    @Override
    public Boolean updateClassifyByCoding(GgGoods goods) {
        LambdaUpdateWrapper<GgProduct> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(GgProduct::getCoding,goods.getGcode()).set(GgProduct::getClassify,goods.getClassify());
        ggProductDao.update(null,wrapper);
        return true;
    }
}

